package com.example.demo.controller;

import com.example.demo.bean.submitIM;
import com.example.demo.service.submitService;
import jdk.nashorn.internal.ir.RuntimeNode;
import org.apache.coyote.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author admin
 * @version 1.0.0
 * @ClassName login.java
 * @Description TODO
 * @createTime 2020年10月20日 14:09:00
 * 用于处理登录 注册 忘记密码
 */
@Controller
public class login {
    @Autowired
    submitService submitService;

    @RequestMapping("/login")
    public String login(String username, String password){
            //先检测用户名和密码是否匹配 不匹配就返回错误提示 若匹配根据不同用户跳转不同页面
        submitIM findaccount = submitService.findaccount(username);
        System.out.println(findaccount);
        //0 1 2 分别对应物业 住户 访客
        //注意不要等于 用equals
        if(findaccount.getPassword().equals(password)){
           if(findaccount.getIdentity()==0){

               return "property";
           }else if (findaccount.getIdentity()==1){
               return "resident";
           }else {
               return "visitor";
           }
        }else {

            System.out.println("密码错误");
                return "index";
        }
        }


    @RequestMapping("/register")
    public String register(HttpSession session){//封装传入bean类

            return "";//返回登录界面
        }

    @RequestMapping("/ForgetPassword")
    public String Forget(String phone,String VCode,String NewPassword){//传入手机号 验证码 新密码

            return "";//返回登录界面
        }


}
